#include <rtthread.h>
#include "base.h"

/* LED 任务：心跳指示 */
static void led_task(void *p)
{
    RT_UNUSED(p);
    while (1)
    {
        static int log = 0;
        rt_kprintf("log %d\n", log++);
        rt_thread_mdelay(500);
    }
}

/* 日志任务：打印调试信息 */
static void log_task(void *p)
{
    RT_UNUSED(p);
    while (1)
    {
        led_toggle(LED1);
        rt_thread_mdelay(500);
    }
}

int main(void)
{
    hardware_init();
    led_init(LED0);

    /* 创建并启动 LED 任务 */
    rt_thread_t tid_led = rt_thread_create("led", led_task, RT_NULL, 1024, 10, 10);
    if (tid_led) rt_thread_startup(tid_led);

    /* 创建并启动日志任务 */
    rt_thread_t tid_log = rt_thread_create("log", log_task, RT_NULL, 1024, 20, 10);
    if (tid_log) rt_thread_startup(tid_log);

    /* 运行5秒后挂起日志任务 */
    rt_thread_mdelay(5000); 
    rt_kprintf("suspend log task\n");
    rt_thread_suspend(tid_log);

    /* 再运行5秒后恢复日志任务 */
    rt_thread_mdelay(5000);
    rt_kprintf("resume log task\n");
    rt_thread_resume(tid_log);

    return 0;
}